package com.shop.admin.controller;

import com.shop.Result.LdbzResult;
import com.shop.admin.service.AdminMenuService;
import com.shop.pojo.LdbzAdminMenu;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/admin/menu/service")
public class AdminMenuController {

    private static final Logger logger = LoggerFactory.getLogger(AdminMenuController.class);

    @Autowired
    private AdminMenuService adminMenuService;

    @RequestMapping(value="/editAdminMenu/{id}" , method = RequestMethod.GET)
    public LdbzResult editAdminMenu(@PathVariable("id")long id , Model model) {
        return adminMenuService.selectByKey(id);
    }

    @RequestMapping(value="/getAdminMenuPage" , method = RequestMethod.GET)
    public LdbzResult getAdminMenuPage(LdbzAdminMenu entity , int page , int limit) {
        return adminMenuService.getAdminMenuPage(entity, page, limit);
    }

    @RequestMapping(value="/getMenuTree" , method = RequestMethod.GET)
    public LdbzResult getMenuTree() {
        return adminMenuService.getMenuTree();
    }

    @RequestMapping(value="/selectByKey/{id}" , method = RequestMethod.GET)
    public LdbzResult selectByKey(@PathVariable("id")long id) {
        return adminMenuService.selectByKey(id);
    }

    @RequestMapping(value="/deleteByKey/{id}" , method = RequestMethod.GET)
    public LdbzResult deleteByKey(@PathVariable("id")String id) {
        return adminMenuService.deleteByKey(id);
    }

    @RequestMapping(value="/insertByEntity" , method = RequestMethod.GET)
    public LdbzResult insertByEntity(LdbzAdminMenu entity) {
        return adminMenuService.insertByEntity(entity);
    }

    @RequestMapping(value="/updateByKey" , method = RequestMethod.GET)
    public LdbzResult updateByKey(LdbzAdminMenu entity) {
        return adminMenuService.updateByKey(entity);
    }
}
